package CarRent;

public class CarManager {
    String name[]={"皖A97302","皖A4932","皖A92F","皖A9014","皖A3023",};//存储车牌信息
    boolean state[]={true,false,true,true,true};//存储借出状态
    int date[] = {0,2,0,0,0};//存储借出天数
    int count[] ={13,9,3,5,0};//存储借出次数
    int moneys[] ={119,110,120,111,101};
    String str;
    public String addCar(String number , int money){

        if(name.length<6){
            name[name.length]= number;
            state[name.length]=true;
            date[name.length]=0;
            count[name.length]=0;
            moneys[name.length]=money;
            str="添加成功！";
        }else {
            str="车库已满！";
        }
        return str;
    }
    public String serCar(){
        String states;
        String str ="序号"+"\t\t\t\t"+ "车辆信息"+"\t\t\t\t"+"状态"+"\t\t\t"+ "借出日期"+"\t\t\t"+ "借出次数"+"\t\t\t"+ "日租金"+"\n";
        for (int i = 0; i <name.length ; i++) {
            if(state[i]==true){
                states = "在库";
            }else {
                states = "出库";
            }
            str=str+i+"\t\t\t\t"+name[i]+"\t\t\t\t"+states+"\t\t\t\t"+date[i]+"\t\t\t\t"+count[i]+"\t\t\t"+moneys[i]+"\n";
        }
        return str;
    }
    public String delCar(String number){
            for (int i = 0; i <name.length ; i++) {
            if(name[i]==number){
                name[i]=null;
                state[i]=false;
                date[i]=0;
                count[i]=0;
                moneys[i]=0;
                for (int j = i+1; j < name.length ; j++) {
                    name[i]=name[j];
                    state[i]=state[j];
                    date[i]=date[j];
                    count[i]=count[j];
                    moneys[i]=moneys[j];
                }
                str="删除成功！";
            }
                str="该车不存在！";
        }
        return str;
    }
    public String catCar(String number){

        for (int i = 0; i <name.length ; i++) {
            if(name[i]==number){
                if(state[i]==false){
                    str="该车已借出！";
                }else {
                    str="借车成功！";
                }
            }
                str="该车不存在！";
            }
        return str;
    }
    public String givCar(String number){

        for (int i = 0; i <name.length ; i++) {
            if(name[i]==number){
                if(state[i]==false){
                    str="还车成功！";
                }else {
                    str="该车已在库！";
                }
            }
            str="该车不存在！";
        }
        return str;
    }
}
